#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <climits>

using namespace std;


int main(){
    freopen("in.txt","r",stdin);
    int n;
    cin >> n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    int A=0,B=0,v[2*n]; //A,B ans, v mo'ni
    int ai=0,bi=0;
    int mp[14],cnt=0;//1-13 wei'zhi
    memset(mp,-1,sizeof(mp));
   // cout <<"hello"<<endl;
    while(ai<n||bi<n){
       // cout << ai << " " << bi << " "<< cnt <<endl;
        if(ai<n){
            if(mp[a[ai]]==-1){
                v[cnt]=a[ai];
                mp[a[ai]]=cnt;
                ai++;
                cnt++;
            }else{
                //has it
                A+=cnt-mp[a[ai]]+1;    
              //  cout << A << " "<<  mp[a[ai]] << " " << cnt <<endl;     
                int t=cnt;   
                cnt=mp[a[ai++]];  
                //cout << cnt <<endl;  
                for(int j=cnt;j<t;j++){
                        mp[v[j]]=-1;
                }
                if(ai<n)
                    v[cnt++]=a[ai++];
                //cout << cnt << " "<< mp[cnt]<<endl;
            }
        }
        if(bi<n){
            if(mp[b[bi]]==-1){
                v[cnt]=b[bi];
                mp[b[bi]]=cnt;
                bi++;
                cnt++;
            }else{
                B+=cnt-mp[b[bi]]+1;
                int t=cnt;
                cnt=mp[b[bi++]];
                for(int j=cnt;j<t;j++){
                        mp[v[j]]=-1;
                }
                if(bi<n)
                    v[cnt++]=b[bi++];
            }
        }
    }
    
   //cout << cnt << " "<<v[0]<<endl;
    if(cnt){
        for(int i=0;i<cnt;i++){
            if(v[i]&1){
                A++;
            }else{
                B++;
            }
        }
    }
    cout << A << " " <<B <<endl;

    return 0;
}